<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <cpn :number1="num1" :number2="num2" @change-num1="change1" @change-num2="change2"></cpn>
  </div>

  <template id="cpn">
    <div>
      <div>props:{{number1}}</div>
      <div>data:{{dnumber1}}</div>
      <div><input type="text" v-model="dnumber1"></div>
      <div>props:{{number2}}</div>
      <div>data:{{dnumber2}}</div>
      <div><input type="text" v-model="dnumber2"></div>

    </div>
  </template>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        num1: 1,
        num2: 2
      },
      methods: {
        change1(val) {
          this.num1 = val - 0
        },
        change2(val) {
          this.num2 = val - 0
        }
      },
      components: {
        cpn: {
          template: '#cpn',
          props: {
            number1: { type: Number },
            number2: { type: Number }
          },
          data() {
            return {
              dnumber1: this.number1,
              dnumber2: this.number2
            }
          },
          watch: {
            dnumber1(newValue) {
              this.$emit('change-num1', newValue)
            },
            dnumber2(newValue) {
              this.$emit('change-num2', newValue)
            }
          }
        }
      }
    });
  </script>
</body>

</html>